package edu.wuster.blog.controller;


import edu.wuster.blog.entity.Admin;
import edu.wuster.blog.entity.Result;
import edu.wuster.blog.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@Slf4j
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    //管理员登录
    @PostMapping("/login")
    public Result adminLogin(@RequestBody Admin admin) {
        log.info("管理员（adminName：{}）正在登录", admin.getAdminname());
        String jwt = adminService.adminLogin(admin);
        log.info("登录成功");
        return Result.success(jwt);
    }
}
